<template>
	<sc-water-mark ref="wm" :text="waterMarkContent" :subtext="waterMarkSubtext" :showWater="waterMark=='1'" style="height: 100%;">
	<div id="mypdf"></div>
	</sc-water-mark>
</template>

<script>
import PDFObject from 'pdfobject'
import config from "@/config"
import tool from "@/utils/tool";
export default {
	data() {
		return {
			extName:this.$route.query.extName,
			attachId:this.$route.query.attachId,
			netDiskId:this.$route.query.netDiskId,
			isNetDisk:this.$route.query.isNetDisk,
			waterMarkContent: '',
			waterMarkSubtext: '',
			waterMark: '0',
		}
	},
	mounted() {
		this.waterMark = this.$TOOL.data.get("WATER_MARK");
		this.waterMarkContent = this.$TOOL.data.get("WATER_MARK_CONTENT");
		this.waterMarkSubtext = this.$TOOL.data.get("WATER_MARK_SUBTEXT");
		if(this.isNetDisk=='true')
		{
			let url = "";
			if(config.SM4_PRIVATE_KEY!='')
			{
				url = config.API_URL+'/get/file/readPdfOnLine?netDiskId=' + tool.crypto.createParam(this.netDiskId) + "&fileName=" + tool.crypto.createParam(this.attachId);
			}else{
				url = config.API_URL+'/get/file/readPdfOnLine?netDiskId=' + this.netDiskId + "&fileName=" + encodeURIComponent(this.attachId);
			}
			PDFObject.embed(url, "#mypdf");
		}else {
			let url="";
			if(config.SM4_PRIVATE_KEY!='')
			{
				url = config.API_URL+'/get/file/readPdfOnLine?attachId=' + tool.crypto.createParam(this.attachId);
			}else{
				url = config.API_URL+'/get/file/readPdfOnLine?attachId=' + this.attachId;
			}

			PDFObject.embed(url, "#mypdf");
		}
	}
}
</script>

<style scoped>
.pdfobject-container {
	height: 100%;
}
</style>
<!--

<template>
	<vue-office-pdf :src="pdf" @rendered="rendered"/>
</template>

<script>
import VueOfficePdf from '@vue-office/pdf'
export default {
	components:{
		VueOfficePdf
	},
	data(){
		return {
			pdf: "capi/get/file/getFileDown?attachId="+this.$route.query.attachId //设置文档地址
		}
	},
	methods:{
		rendered(){
			console.log("渲染完成")
		}
	}
}
</script>
-->
